Skip to content

Fix MATCH_SET parsing of quoted items and add tests#13024

Merged
cmcfarlen merged 3 commits intoapache:masterfrom
cmcfarlen:hrw-fix-set-parse-quote
Apr 7, 2026
Merged

Fix MATCH_SET parsing of quoted items and add tests#13024
cmcfarlen merged 3 commits intoapache:masterfrom
cmcfarlen:hrw-fix-set-parse-quote

Conversation

@cmcfarlen
Copy link
Copy Markdown
Contributor

The set parser was incorrectly advancing 'start' by skip_quotes after a comma, causing the second and subsequent quoted items to be parsed with their leading characters truncated.

Add a unit test for quoted set parsing and enable the test_matcher build target (fix linker issue by removing resources.cc and adding stubs). Add autest coverage for quoted sets in header_rewrite bundle.

The set parser was incorrectly advancing 'start' by skip_quotes
after a comma, causing the second and subsequent quoted items to
be parsed with their leading characters truncated.

Add a unit test for quoted set parsing and enable the test_matcher
build target (fix linker issue by removing resources.cc and adding
stubs). Add autest coverage for quoted sets in header_rewrite
bundle.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cmcfarlen cmcfarlen added this to the 11.0.0 milestone Mar 26, 2026
@cmcfarlen cmcfarlen self-assigned this Mar 26, 2026
@cmcfarlen cmcfarlen added the header_rewrite header_rewrite plugin label Mar 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes MATCH_SET parsing in the header_rewrite plugin so quoted list items after the first element aren’t truncated, and adds regression coverage in both unit tests and gold tests.

Changes:

  • Adjust MATCH_SET parsing cursor advancement for quoted items.
  • Add Catch2 unit test coverage for quoted set parsing.
  • Add gold test rules and replay transactions to validate quoted set matching behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/gold_tests/pluginTest/header_rewrite/rules/rule_client.conf Adds a new rule to exercise quoted set matching in SEND_RESPONSE_HDR_HOOK.
tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.replay.yaml Adds two replay transactions validating quoted set match/non-match behavior.
plugins/header_rewrite/matcher_tests.cc Adds stubs to make matcher tests linkable without full resources implementation and adds a quoted set unit test.
plugins/header_rewrite/matcher.h Changes MATCH_SET parsing to avoid truncating subsequent quoted items.
plugins/header_rewrite/CMakeLists.txt Adjusts (commented) test_matcher target lines and linker notes/handling.

@bryancall bryancall requested review from bryancall and removed request for bneradt March 30, 2026 22:23
headers:
fields:
- [ Host, www.example.com ]
- [ X-Quoted-Set, "bar" ]
Copy link
Copy Markdown
Contributor

@bneradt bneradt Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "bar" really quoted by the time this traffic is replayed? I think yaml will just see the quotes and understand this as a string type, right?

Might need to escape the quotes:

        - [ X-Quoted-Set, "\"bar\"" ]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quotes are on the hrw side. The header side are not expected to be quotes. These extra checks are to test that values past the first on match.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. The comment at line 317 threw me off. I thought this needed to test Proxy Verifier handing down literal quoted strings.

Copy link
Copy Markdown
Contributor

@bneradt bneradt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@cmcfarlen cmcfarlen merged commit 52688fe into apache:master Apr 7, 2026
19 checks passed
@cmcfarlen cmcfarlen deleted the hrw-fix-set-parse-quote branch April 7, 2026 21:38
@github-project-automation github-project-automation bot moved this to For v10.2.0 in ATS v10.2.x Apr 7, 2026
@cmcfarlen cmcfarlen moved this from For v10.2.0 to Picked v10.2.0 in ATS v10.2.x Apr 8, 2026
@cmcfarlen cmcfarlen modified the milestones: 11.0.0, 10.2.0 Apr 8, 2026
@cmcfarlen
Copy link
Copy Markdown
Contributor Author

Cherry-picked to 10.2.x

cmcfarlen added a commit that referenced this pull request Apr 8, 2026
* Fix MATCH_SET parsing of quoted items and add tests

The set parser was incorrectly advancing 'start' by skip_quotes
after a comma, causing the second and subsequent quoted items to
be parsed with their leading characters truncated.

Add a unit test for quoted set parsing and enable the test_matcher
build target (fix linker issue by removing resources.cc and adding
stubs). Add autest coverage for quoted sets in header_rewrite
bundle.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* link cripts to test if enabled

* nevermind, that test is cursed

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
(cherry picked from commit 52688fe)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

header_rewrite header_rewrite plugin

Projects

Status: Picked v10.2.0

Development

Successfully merging this pull request may close these issues.

3 participants